%PUT BUILDING TABLE 3 FOR &TITLE2....;

**********************************************************
	* TABLE 3 THIS POINT DOWN *;
**********************************************************;
PROC REG DATA=OUT.&COM OUTEST=BUNADJ (DROP=&RHYRS _MODEL_ _TYPE_ _DEPVAR_ _RMSE_ LNPRICE); 
	MODEL LNPRICE=&RHYRS DISCDEP SMGROC CONVENC WAREHS OTHSTORE;
	TITLE "UNADJUSTED DISCOUNTS BY STORE CATEGORY FOR TABLE 3";
	TITLE2 "&TITLE2";
RUN;

PROC PRINT DATA=BUNADJ;
RUN;

**********************************************************
	* TABLE 4 THIS POINT DOWN *;
**********************************************************;

%PUT BUILDING TABLE 4 FOR &TITLE2...;

PROC REG DATA=OUT.&COM OUTEST=BADJ (DROP=&RHYRS &RHS _MODEL_ _TYPE_ _DEPVAR_ _RMSE_ LNPRICE); 
	MODEL LNPRICE=&RHYRS &RHS DISCDEP WAREHS SMGROC CONVENC OTHSTORE;
	TITLE "ADJUSTED DISCOUNTS BY STORE CATEGORY FOR TABLE 4";
	TITLE2 "&TITLE2";
RUN;

PROC PRINT DATA=BADJ;
RUN;

**********************************************************
	* FIGURE 2 THIS POINT DOWN *;
**********************************************************;

/* RHS WITHOUT SIZE VARS */
%MACRO DOTHIS;
	%GLOBAL RHS_NOSIZE; %LET RHS_NOSIZE = ;
	%LET RHS_INDX = 1;
	%LET RHS_VAR = %SCAN(&RHS, &RHS_INDX);
	%DO %WHILE (&RHS_VAR NE);
		%IF &RHS_VAR NE MNAMT AND &RHS_VAR NE MNAMTSQ %THEN %DO;
			%LET RHS_NOSIZE = &RHS_NOSIZE &RHS_VAR;
		%END;
		%LET RHS_INDX = %EVAL(&RHS_INDX + 1);
		%LET RHS_VAR = %SCAN(&RHS, &RHS_INDX);
	%END;
%MEND; %DOTHIS;

%PUT CONSTRUCTING FIGURE 2 FOR &TITLE2....;

PROC REG DATA=OUT.&COM OUTEST=FIG2 (DROP=&RHYRS &RHS_NOSIZE _MODEL_ _TYPE_ _DEPVAR_ _RMSE_ LNPRICE); 
	MODEL LNPRICE=&RHYRS &RHS_NOSIZE DISCDEP WAREHS SMGROC CONVENC OTHSTORE;
	TITLE "ADJUSTED DISCOUNTS BY STORE CATEGORY (NO SIZE VARS) FOR FIGURE 2";
	TITLE2 "&TITLE2";
RUN;

DATA BDISCS; SET BUNADJ BADJ FIG2;
RUN;

PROC EXPORT DATA=BDISCS OUTFILE=OUTDISCS
	DBMS=EXCEL REPLACE;
	SHEET=%LOOKUP(&COM);	
RUN;
